package org.railage.server.entities;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

import org.hibernate.annotations.NamedNativeQueries;
import org.hibernate.annotations.NamedNativeQuery;
import org.railage.common.dto.TripThroughTwoStationsDTO;

/**
 * TripThroughTwoStations entity
 * 
 * @author Cyril Fertikov
 * 
 */
@NamedNativeQueries({
		@NamedNativeQuery(
				name = "getTrips_A_B", 
				query = "call proc_get_trips_A_B(:station_A,:station_B)", 
				resultClass = TripThroughTwoStations.class
		),
		@NamedNativeQuery(
				name = "getTrips_A_B_duration", 
				query = "call proc_get_trips_A_B_duration(:station_A,:station_B,:duration)", 
				resultClass = TripThroughTwoStations.class
		),
		@NamedNativeQuery(
				name = "getTrips_A_B_dep_arr", 
				query = "call proc_get_trips_A_B_dep_arr(:station_A,:station_B,:departure,:arrival)", 
				resultClass = TripThroughTwoStations.class
		) 
})
@Entity
public class TripThroughTwoStations implements Serializable {

	private static final long serialVersionUID = 4040391975267565496L;

	@Id
	@Column(name = "trip_id")
	private int trip;

	@Column(name = "route_name")
	private String routeName;

	@Column(name = "departure_from_A")
	private Timestamp departureFromA;

	@Column(name = "arrival_to_B")
	private Timestamp arrivalToB;

	@Column(name = "trip_duration")
	private String duration;

	public int getTrip() {
		return trip;
	}

	public void setTrip(int trip) {
		this.trip = trip;
	}

	public String getRouteName() {
		return routeName;
	}

	public void setRouteName(String routeName) {
		this.routeName = routeName;
	}

	public Timestamp getDepartureFromA() {
		return departureFromA;
	}

	public void setDepartureFromA(Timestamp departureFromA) {
		this.departureFromA = departureFromA;
	}

	public Timestamp getArrivalToB() {
		return arrivalToB;
	}

	public void setArrivalToB(Timestamp arrivalToB) {
		this.arrivalToB = arrivalToB;
	}

	public String getDuration() {
		return duration;
	}

	public void setDuration(String duration) {
		this.duration = duration;
	}

	public TripThroughTwoStationsDTO toDTO() {
		TripThroughTwoStationsDTO dto = new TripThroughTwoStationsDTO();
		dto.setTrip(trip);
		dto.setRouteName(routeName);
		dto.setDepartureFromA(departureFromA);
		dto.setArrivalToB(arrivalToB);
		dto.setDuration(duration);
		return dto;
	}

	@Override
	public String toString() {
		return "TripThroughTwoStations [trip=" + trip + ", departureFromA="
				+ departureFromA + ", arrivalToB=" + arrivalToB + ", duration="
				+ duration + "]";
	}

}
